import http from '@/utils/http'

const BASE_URL = '/cakerun/order/project'

export interface OrderResp {
  id: string
  accountId: string
  name: string
  shopId: string
  cnt: string
  realPayed: string
  bizCost: string
  service: string
  due: string
  partnerSelfDeliverFee: string
  businessTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface OrderDetailResp {
  id: string
  accountId: string
  name: string
  shopId: string
  cnt: string
  realPayed: string
  bizCost: string
  service: string
  due: string
  partnerSelfDeliverFee: string
  businessTime: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface OrderQuery {
  sort?: Array<string>
  accountId?: Array<string>
}
export interface OrderPageQuery extends OrderQuery, PageQuery {}

/** @desc 查询每日收益列表 */
export function listOrder(query: OrderPageQuery) {
  return http.get<PageRes<OrderResp[]>>(BASE_URL, query)
}

/** @desc 查询每日收益详情 */
export function getOrder(id: string) {
  return http.get<OrderDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增每日收益 */
export function addOrder(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改每日收益 */
export function updateOrder(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除每日收益 */
export function deleteOrder(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出每日收益 */
export function exportOrder(query: OrderQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
